Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update circular-buffer example.jl #717

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

depial
Copy link
Contributor

@depial depial commented Mar 28, 2024

Unwrapped the modules in example.jl in an attempt to resolve error occurring in Julia nightly - OS check suite.

Initial error read:

WARNING: both CircularBuffers and Base export "isfull"; uses of it in module anonymous must be qualified
When empty: Error During Test at /home/runner/work/julia/julia/exercises/practice/circular-buffer/runtests.jl:160
  Test threw exception
  Expression: isfull(cb) == false
  UndefVarError: `isfull` not defined in `Main.anonymous`
  Hint: It looks like two or more modules export different bindings with this name, resulting in ambiguity. Try explicitly importing it from a particular module, or qualifying the name with the module it should come from.
  Hint: a global variable of this name also exists in Base.

I am unaware of an isfull method in Base, however, for my first attempt at a fix, I tried to add change the isfull methods to Base.isfull, which fixed the Julia nightly - OS checks, but broke the others, with the following error message:

circular-buffer: Error During Test at /home/runner/work/julia/julia/runtests.jl:19
  Got exception outside of a @test
  LoadError: LoadError: UndefVarError: isfull not defined

Disposing off the module wrappers in example.jl seems to have fixed the issue. However, why this issue appeared should probably be looked into.

Unwrapped the modules in an attempt to resolve error occurring in nightly check suite.
@depial
Copy link
Contributor Author

depial commented Mar 28, 2024

All of the checks are passing now, but this fix is probably only a stop-gap. It would be great if @cmcaine could take a closer look at the underlying problem.

@ErikSchierboom
Copy link
Member

@cmcaine I'm merging this to unblock CI

@ErikSchierboom ErikSchierboom merged commit 490b9c0 into exercism:main Mar 28, 2024
11 checks passed
@depial depial deleted the circular-buffer branch March 28, 2024 14:07
@cmcaine
Copy link
Contributor

cmcaine commented Apr 3, 2024

This fix is fine. The underlying issue is that Julia 1.11 exports an isfull function and that's clashing with the isfull function we're importing with the unqualified using expressions in example.jl (similar to from X import * in other languages).

We didn't encourage students to use modules or using, so this shouldn't cause issues for many students. I don't remember who wrote the example, but they're probably only in modules because I was writing them at a REPL (you can't redefine a struct, but you can redefine a module).

If we cared about keeping the modules (which I don't) then we could have fixed it by conditionally importing Base.isfull in each of the modules, as DataStructures.jl now does: https://github.com/JuliaCollections/DataStructures.jl/pull/896/files

# Base might define `isfull` from julia 1.11 onwards, see julia PR #53159
if isdefined(Base, :isfull)
    import Base: isfull
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants